<layout name="user" />
<!-- 搜索 -->
<div id="search" class="clearfix">
    <a class="prev fl" href="{:U('Face/Index/index')}" title="后退">&lt;</a>
    <div class="head fl">购物车</div>
</div>
<!-- 搜索 -->

<!-- 内容 -->
<div id="switch">
    <div id="cont" class="clearfix">
        <form action="" method="post" onsubmit="return validate_form(this)">
            <ul class="listFive mt10">
                <volist name="data" id="vo">
                <li class="bt0">
                    <input type="checkbox" id="listInput" class="listInput" checked="checked" />
                    <label for="listInput" class="listLabel fl"></label>
                    <img src="__ROOT__/data/upload/{$vo.goodid.goods_thumb}" class="listImg fl" />
                    <div class="listDiv fl"><a href="#">
                        <h4 class="listSp">商品名</h4>
                        <div class="listJs">{$vo.goodid.goods_name}</div>
                        <div class="listJs">
                            <p class="unit fl">单价：{$vo.goodid.goods_xiaoshou}元</p>
                            <p class="p_num fl">
                                <span class="sy_minus fl" id="sy_minus_gid1">-</span>
                                <input type="text" name="number[]" value="{$vo.goodnum}" class="sy_num fl" id="sy_num_gid1" readonly />
                                <input type="text" name="goodid[]" value="{$vo.goodid.id}" class="sy_num fl" id="sy_num_gid1" readonly />
                                <span class="sy_plus fl" id="sy_plus_gid1">+</span>
                            </p>
                            <p class="unit" style="display:none;">需支付：{$vo.goodid.goods_xiaoshou}元</p>
                        </div>
                    </a></div>
                    <a href="{:U('Face/Shopcar/del',['id'=>$vo['id']])}" class="listDele fr">删除</a>
                </li>
                </volist>
            </ul>
            <div class="listFive_fot">
                <input type="checkbox" id="xzXkxy" class="xzXkxy" checked="checked" />
                <label for="xzXkxy" class="tyXkxy fl">全选</label>
                <i class="i_hj fr">合计：{$vo.goodid.goods_xiaoshou}元</i>
            </div>
            <input type="submit" value="结算付款" name="submit" class="footSubmit" />
        </form>
    </div>
</div>
<!-- 内容 -->

<!-- javascript -->
<script type="text/javascript">
    //购物车
    $(document).ready (function ()
    {
        var pl = $("i:last");
        var reg = /(.*[\:\：]\s*)([\+\d\.]+)(\s*元)/g;
        $ (".sy_minus").click (function ()
        {
            var me = $ (this), txt = me.next (":text"), pc = me.closest("p");
            var val = parseFloat (txt.val ());
            val = val < 1 ? 1 : val;
            txt.val (val - 1);
            var price = parseFloat (pc.prev("p").text().replace(reg,'$2')) * txt.val ();
            pc.next("p").text (pc.next("p").text().replace(reg, "$1" + price + "$3"));
            var sum = 0;
            $(".p_num").next("p").each(function (i, dom)
            {
                sum += parseFloat ($(this).text().replace(reg, "$2"));
            });
            pl.text(pl.text().replace(reg, "$1" + sum + "$3"));
        });

        $(".sy_plus").click (function ()
        {
            var me = $ (this), txt = me.prev (":text"), pc = me.closest("p");
            var val = parseFloat (txt.val ());
            txt.val (val + 1);
            var price = parseFloat (pc.prev("p").text().replace(reg,'$2')) * txt.val ();
            pc.next("p").text (pc.next("p").text().replace(reg, "$1" + price + "$3"));
            var sum = 0;
            $(".p_num").next("p").each(function (i, dom)
            {
                sum += parseFloat ($(this).text().replace(reg, "$2"));
            });
            pl.text(pl.text().replace(reg, "$1" + sum + "$3"));
        });
    })[0].onselectstart = new Function ("return false");
</script>
<!-- javascript -->